package chapter6;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 求一个整数各位之和
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc6_2 {
	
	public static int sumDigits(long n) {
		
		int sum=0;
		
		while(n>0) {
			sum+=n%10;
			n/=10;
		}
		
		return sum;
		
	}
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter an integer :");
		long n=input.nextLong();
		
		System.out.print("sum of digits : "+sumDigits(n));
		
	}

}
